
import wxUtil from "./wxUtils.js"

export async function wxShare(option) {
  let { title, desc, link } = option
  await wxUtil.initConfig()
  wxUtil.executeOptions.onMenuShareAppMessage = { title, desc, link }
  wxUtil.executeOptions.onMenuShareTimeline = { title, desc, link }
  wxUtil.executeOptions.showMenuItems = {
    menuList: ["menuItem:share:appMessage", "menuItem:share:timeline"]
  }
  wxUtil.initConfigLoading && wxUtil.execute(["hideOptionMenu", "onMenuShareAppMessage", "onMenuShareTimeline", "showMenuItems"])
}

export async function WxhideOptionMenu() {
  await wxUtil.initConfig()
  wxUtil.initConfigLoading && wxUtil.execute(["hideOptionMenu"])
}

// 微信授权并获取用户信息
export function oauth() {
  var APPID = "wx92e23e5b5cfee7c3";
  let callbackUrl = encodeURIComponent("http://39.98.134.216:7000/redirect.html?router_path=about&c=3&g=3")
  location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${APPID}&redirect_uri=${encodeURIComponent("http://39.98.134.216/oauth/index.php")}&response_type=code&scope=snsapi_userinfo&state=${callbackUrl}&connect_redirect=1#wechat_redirect`
}